//
//  ViewController.m
//  day1-demo1
//
//  Created by Maggie on 15/8/1.
//  Copyright (c) 2015年 fmning. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

//属性nameField表示视图上的输入框
@property (weak, nonatomic) IBOutlet UITextField *usernameField;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)sayHelloClicked:(UIButton *)sender {
    //点击sayhello按钮处理业务
    
    //第一步，获取用户输入的姓名
    NSString *name = self.usernameField.text;
    
    //控制台打印日志信息
//    NSLog(@"您输入的姓名是:%@",name);
    //第二步，弹出提示框，显示内容"hi，某某"
//    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"打招呼" message:name delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:@"Cancle", nil];
    
    //alloc方法申请内存
    UIAlertView *alert = [UIAlertView alloc];
    
    NSString *message = [[NSString alloc] initWithFormat:@"hello,%@",name];
    
    //init初始化
    alert = [alert initWithTitle:@"打招呼" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:@"Cancle", nil];
    
    //第三步,显示出来
    [alert show];
    
}

@end




